package net.linlan.plat.comm.aspect;

import net.linlan.commons.core.CoreException;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 *
 * Filename:DataFilterAspect.java
 * Desc:数据过滤，切面处理类
 *
 * @author Linlan
 * CreateTime:2017/8/29 9:38
 *
 * @version 1.0
 * @since 1.0
 *
 */
@Aspect
@Component
public class DataFilterAspect {

    @Pointcut("@annotation(net.linlan.commons.db.annotation.DataFilter)")
    public void dataFilterCut() {

    }

    @Before("dataFilterCut()")
    public void dataFilter(JoinPoint point) throws Throwable {
        Object params = point.getArgs()[0];
        if(params != null && params instanceof Map){

            return ;
        }

        throw new CoreException("要实现数据权限接口的参数，只能是Map类型，且不能为NULL");
    }


}
